#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define str string
#define all(x) (x).begin(),(x).end()
#define ms(a,t) memset(a,t,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define db double
const int maxn = 1e3+10;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const db eps = 1e-7;
ll fp(ll x,ll y) {
	ll ret = 1;
	while(y > 0) {
		if(y & 1) ret = ret * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return ret;
}
ll inv[maxn],fac[maxn];
void init(const int T = 1e6) {
	fac[0] = 1; for(int i = 1; i <= T; i++) fac[i] = fac[i-1] * i % mod;
	inv[T] = fp(fac[T],mod-2); 
	for(int i = T-1; i >= 0; i--) inv[i] = inv[i+1] * (i+1) % mod; 
}
ll C(ll x,ll y) {
	if(x < y || y < 0 || x < 0)  return 0;
	return fac[x] * inv[y] % mod * inv[x-y] % mod;
}
int n,k;
ll f[maxn][2][maxn];
char s[maxn];
char a[maxn],b[maxn];
ll p[maxn];

ll dfs(int pos,ll v,bool l,bool r,int res,bool fg) {
	if(pos == n) {
//		cerr<<pos<<' '<<v<<' '<<l<<' '<<r<<' '<<res<<' '<<fg<<'\n';
		return v*(res == 0);
	}
	if(!l && !r) {
//		cerr<<pos<<' '<<v<<' '<<l<<' '<<r<<' '<<res<<' '<<fg<<' '<<f[pos][fg][res]+v*p[n-pos]%mod*C(n-pos,res)%mod<<'\n';
		return f[pos][fg][res]+v*p[n-pos]%mod*C(n-pos,res)%mod;
	}
	int vl = (l ? a[pos+1]-'0' : 0);
	int vr = (r ? b[pos+1]-'0' : 1);
	ll ret = 0;
	for(int cur = vl; cur <= vr; cur++) {
		int nr = res - (fg ^ (s[pos]=='R') ^ cur);
		if(nr < 0) continue;
		ret += dfs(pos+1,(v*2+cur)%mod,
		l&(cur==a[pos+1]-'0'),r&(cur==b[pos+1]-'0'),nr,(s[pos]=='R')^cur);
	}
	return ret % mod;
}
void Solve() {
	cin >> n >> k;
	init(n);
	p[0] = 1; for(int i = 1; i <= n; i++) p[i] = p[i-1] * 2 % mod;
	for(int i = 1; i < n; i++) {
		cin >> s[i];
	}
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	
	for(int i = n-1; i >= 1; i--) for(int st = 0; st < 2; st++) {
		f[i][st][0] = (f[i+1][st][0] + ((s[i] == 'R') ^ st)*p[n-i-1]) % mod;
		for(int j = 1; j <= k && j <= n-i; j++) {
			f[i][st][j] = (f[i+1][st][j] + f[i+1][st^1][j-1] + p[n-i-1]*C(n-i-1,j-((s[i] == 'L') ^ st)))%mod;
		}
	}
	ll ret = dfs(1,1,1,1,k,0)+dfs(1,1,1,1,k,1);
	cout<<ret%mod<<'\n';
}
int main() {
	freopen("lost.in","r",stdin);
	freopen("lost.out","w",stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
//	cin >> T;
	while(T--) {
		Solve();
	}
	return 0;
}
